Repository navigation
Replace PAT with github login - #8
Merged
Merged
Conversation
Sign in with the GitHub account through the OAuth device flow instead of pasting a personal access token. The access token is stored in the existing credential store, and a previously saved token is removed. The OAuth App client id is read from KONTEXT_GITHUB_CLIENT_ID.
Member
Author
|
Cut down the file size, take SOLID and KISS in mind |
Move the HTTP transport into GitHubFormPoster and the token result types into their own file, so GitHubDeviceLogin only holds the flow. Split the large device login and shell view model test files by responsibility and drop duplicated cases. Behaviour is unchanged.
Member
Author
|
Split the device login code and tests into smaller files. The HTTP transport now lives in GitHubFormPoster and the token result types have their own file, so GitHubDeviceLogin only holds the flow (118 to 69 lines). The 519-line device login test file is split into a shared base, Start tests and Wait tests, and the shell view model tests into a fixture, the main tests and the sign-in tests. Duplicated test cases were removed or merged; behaviour and messages are unchanged. Build and the full test suite pass. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The personal access token sign-in is replaced by signing in with a GitHub account through the OAuth device flow. The user gets a short code, approves it on github.com, and the app receives an access token without any password or token being typed or any client secret shipped.
What changed
Kontext.GitHub(GitHubDeviceLogin, response parsing inDeviceFlowResponses): requests a device code, polls for the token with the interval GitHub returns (handles pending, slow down, expiry, denial and cancellation), only talks togithub.com/login/device/codeandgithub.com/login/oauth/access_token, and only accepts an httpsgithub.comverification link. New contractIGitHubDeviceLoginand recordDeviceCodeChallenge.ShellViewModel: the token field is gone; signing in shows the code and the verification link, can be cancelled, and signing out cancels a pending sign-in. The token is saved only after GitHub has accepted it.KONTEXT_GITHUB_CLIENT_ID. Without it, the sign-in screen shows a clear "not configured" message. README updated (requirements and a Configuration section).Before this works end to end
KONTEXT_GITHUB_CLIENT_IDto its client id and restart Kontext.Signing out only forgets the token locally; the grant can be revoked in GitHub settings.
Testing
dotnet build Kontext.slnx -c Release: 0 warnings, 0 errors.dotnet test Kontext.slnx -c Release: all projects passed (GitHub 77, Presentation 203, Architecture 27, Composition 19, GitAutomation 111, and the rest). 71 new tests cover the response parsing and the flow with a stubbed HTTP handler and a fake clock (polling, slow down, expiry, denial, cancellation, errors, URI validation, no token in error messages), and 15 new view model tests replace the three removed token tests.Closes #3